package com.bwstudio.demo.consumer.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import com.bwstudio.demo.consumer.client.fallback.EchoClientFallback;
import com.bwstudio.demo.consumer.config.FeignConfiguration;

/**
 * 用feign时发现服务名不能以http或https开头，不然会导致调用服务时无法识别协议unknown protocol: null
 * 	
 * feign中定义的资源名规则为httpmethod:protocol://requesturl
 * 在下面的场景中，你可以在控制台中选择目标资源名为：GET:http://provider-service-by-http-with-sentinel/echo/{str}
 * 
 * feign是用来调用第三方API的接口，所以默认就是出口流量，sentinel资源的entryType默认为EntryType.OUT 
 *
 */
@FeignClient(value = "provider-service-by-http-with-sentinel", 
//	url = "http://localhost:8081", 
	fallback = EchoClientFallback.class, 
	configuration = FeignConfiguration.class)
public interface EchoClient {

	@GetMapping(value = "/echo/{str}")
    String echo(@PathVariable("str") String str);
}
